using System;
using System.Collections;
using System.Text;
using System.Configuration;
using System.Xml;

namespace Services.WCF.Hosting
{
    public class ServiceConfigurationElement : ConfigurationElement
    {
        public ServiceConfigurationElement()
        {
        }

        public ServiceConfigurationElement(String Name, String AssemblyQualifiedName, bool Enabled)
        {
            this.Name = Name;
            this.Enabled = Enabled;
            this.EndPoint = String.Empty;
            this.ConfigFilePath = String.Empty;
            this.AssemblyQualifiedName = AssemblyQualifiedName;
        }

        public ServiceConfigurationElement(String Name, String AssemblyQualifiedName, String ConfigFilePath, bool Enabled)
        {
            this.Name = Name;
            this.Enabled = Enabled;
            this.EndPoint = String.Empty;
            this.ConfigFilePath = ConfigFilePath;
            this.AssemblyQualifiedName = AssemblyQualifiedName;
        }

        public ServiceConfigurationElement(String Name, String AssemblyQualifiedName, String EndPoint, String ConfigFilePath, bool Enabled)
        {
            this.Name = Name;
            this.Enabled = Enabled;
            this.EndPoint = EndPoint;
            this.ConfigFilePath = ConfigFilePath;
            this.AssemblyQualifiedName = AssemblyQualifiedName;
        }

        [ConfigurationProperty("enabled", DefaultValue = false, IsRequired = true)]
        public bool Enabled
        {
            get
            { return (bool)this["enabled"]; }
            set
            { this["enabled"] = value; }
        }

        [ConfigurationProperty("name", DefaultValue = "", IsRequired = true)]
        public String Name
        {
            get
            { return (String)this["name"]; }
            set
            { this["name"] = value; }
        }

        [ConfigurationProperty("assemblyqualifiedname", DefaultValue = "", IsRequired = true)]
        public String AssemblyQualifiedName
        {
            get
            { return (String)this["assemblyqualifiedname"]; }
            set
            { this["assemblyqualifiedname"] = value; }
        }

        [ConfigurationProperty("endpoint", IsRequired = false)]
        public String EndPoint
        {
            get
            {
                return this["endpoint"] == null ? String.Empty : (String)this["endpoint"]; 
            }
            set
            {
                this["endpoint"] = value; 
            }
        }

        [ConfigurationProperty("filepath", DefaultValue = "", IsRequired = false)]
        public String ConfigFilePath
        {
            get
            {
                return this["filepath"] == null ? String.Empty : (String)this["filepath"]; 
            }
            set
            {
                this["filepath"] = value; 
            }
        }
    }
}
